import time
from concurrent.futures.thread import ThreadPoolExecutor

from schedule.scheduled_task import ScheduledTask
from script.run_script import RunScript


def start_scrawl():
    with ThreadPoolExecutor() as executor:
        # 提交任务
        future1 = executor.submit(ScheduledTask(RunScript.run_list_spider).execute, RunScript.run_list_spider, 3,
                                  'run_list_spider')
        future2 = executor.submit(ScheduledTask(RunScript.run_detail_spider).execute, RunScript.run_detail_spider, 4,
                                  'run_detail_spider')

        # 等待任务完成
        future1.result()
        future2.result()

def start_easy():
    RunScript.run_list_spider()
    time.sleep(100)
    RunScript.run_detail_spider()
    time.sleep(14400)
    while True:
        # 运行列表
        RunScript.run_list_spider()
        time.sleep(3600)
        # 爬取详情
        RunScript.run_detail_spider()
        time.sleep(14400)


if __name__ == '__main__':
    start_easy()